package com.itheima.d1_create_thread;

import java.util.concurrent.Callable;

/**
 * 1.实现Callable接口
 */
public class MyCallable implements Callable<String> {
    private int n;
    public MyCallable(int n){
        this.n = n;
    }
    //重写call方法
    @Override
    public String call() throws Exception {
        int sum=0;
        for (int i = 0; i <= n; i++) {
            sum +=i;
        }
        return "线程求出了1-"+n+"的和：" +sum;
    }
}
